<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" 	prefix="s"%>
<%@ include file="/jsp/common/common_head.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>提纲分页映射</title>
<%@ include file="/jsp/common/common_script.jsp"%>
<link href="css/css.css" type="text/css" rel="stylesheet" />
<link href="css/base.css" type="text/css" rel="stylesheet" />
<link href="css/jsmind.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="brainmind/jsmind.js"></script>
<%-- <script type="text/javascript" src="brainmind/jsmind.draggable.js"></script> --%>
<script type="text/javascript" src="canvas/excanvas.js"></script>
<!-- 编辑器引用的文件 start-->
<script type="text/javascript" src="./TGTemplate/tg_core.min.js"></script>
<!-- 编辑器引用的文件 end-->
<!-- 编辑器引用的文件debug start-->
<!--这个标签为通过egret提供的第三方库的方式生成的 javascript 文件-->
	<!--    
	<script egret="lib" src="./TGTemplate/libs/modules/egret/egret.min.js"></script>
	<script egret="lib" src="./TGTemplate/libs/modules/egret/egret.web.min.js"></script>
	<script egret="lib" src="./TGTemplate/libs/modules/res/res.min.js"></script>

	<script type="text/javascript" src="./TGTemplate/resource/shortcut/shortcut.js"></script>
	
	<script src="./TGTemplate/bin-debug/Main.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/DEFINE.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/GCJ_CLASS_TYPE.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/INFO_CODE.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/IdGenerator.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/MESSAGE.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/MessageItem.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/Messager.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/PageInfo.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/TextContourServe.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/graph/CompoundPath.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/graph/FMatrix.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/graph/OnePara.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/graph/ParaChar.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/graph/ParaContour.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/graph/Point.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/graph/PointPath.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/model/CommonModel.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/base/Serializer.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/tg/SJGNode.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/tg3/SJGNodeV3.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/tg/SJGTG.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/tg3/SJGTGV3.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/tg3/SJGRelationV3.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/con/SJGPage.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/base/Parser.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/base/ObjPosition.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/base/ObjConstrain.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/obj/ObjBase.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/base/SJGPageDescribe.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/obj/GroupObj.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/obj/apperance/item/FontStyle.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/obj/TextObj.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/color/FColorBase.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/color/FColor.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/base/ObjPositionAlign.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/base/ObjRelativePosType.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/obj/TextExtObj.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/util/CommonUtil.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/ui/display/TGTemplateDisplay.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/con/SJGDocument.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/con/SJGHead.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/con/SJGDocumentBody.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/base/SJGPageContentDescribe.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/ui/base/LoadingUI.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/TGTemplateKernel.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/con/ObjManager.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/base/SJGObjectIndex.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/color/FGradient.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/con/SJGPageContent.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/obj/ChartObj.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/obj/ImageObj.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/obj/GraphObj.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/obj/ReplaceGroupObj.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/obj/apperance/ChartApperanceBase.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/obj/apperance/item/ChartAxisStyle.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/obj/apperance/item/LineStyle.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/obj/apperance/ChartApperanceLine.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/obj/apperance/ChartApperanceBar.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/obj/apperance/ChartApperancePie.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/replace/SJGReplaceGroup.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/replace/SJGReplaceGroupAdvance.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/replace/SJGReplaceItemBase.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/replace/SJGReplaceItemChart.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/replace/SJGReplaceItemImage.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/replace/SJGSubGroupImageTextOld.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/replace/SJGReplaceItemTable.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/replace/SJGReplaceItemText.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/replace/SJGReplaceItemTitleText.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/replace/SJGSubGroupText.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/replace/SJGSubGroupImageText.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/base/ParserClassLoader.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/tg/TGToDocUtil.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/common/tg3/TGToDocUtilV3.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/editor/TGTemplateEditor.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/base/ParserOfUserReplaces.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/color/FColorConverter.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/kernel/replace/SJGXY.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/ui/base/SJGCopyManager.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/ui/base/SJGGridLine.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/ui/base/SJGRulers.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/ui/base/SJGSelectManger.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/ui/base/SJGSelectRect.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/ui/base/UICreator.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/ui/obj/UIObjBase.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/ui/obj/UIGroupObj.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/ui/obj/UIChartObj.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/ui/obj/UIGraphObj.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/ui/obj/UIGraphShape.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/ui/obj/UIImageObj.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/ui/obj/UIReplaceGroupObj.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/ui/obj/UITextExtObj.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/ui/obj/UITextObj.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/util/OuterCallInterface.js"></script>
	<script src="./TGTemplate/bin-debug/sjg/z/GlobalData.js"></script>
	-->
<!-- 编辑器引用的文件debug end-->
    
<script>
	var g_id='<%=(request.getParameter("id")==null?"":request.getParameter("id"))%>';
	var g_tgId='<%=(request.getParameter("tgId")==null?"":request.getParameter("tgId"))%>';
	
	function getAppServer() {
		//return 'http://localhost:8080/itbour';
		return appPath;
	};
	function pageCount_keyup(THIS){
		var p =Number(THIS.value.replace(/\D/g,''))	;
		p = p>0?p:1;
		p = p<100?p:100;
		THIS.value=p;
		// 初始化下拉列表
		//g_pageCount = p;
		
		initPageList(p);
	}
	
	
	// 根据宽高生成字符串
	function strFromSize(i,id,w,h,d){	
		var idx = Number(i)+1;
		var txt = id+': W('+w+')'+'*H('+h+')@'+(d||'');
		return txt;
	}
	// 从字符串中解析宽高,返回:{width:100,height:200}
	function strToSize(str){
		var str = str.substring(0,str.indexOf('@'));
		var s = str.substr(str.indexOf('W'));
		var s =s.replace(/[WH()]/g,"");
		var s = s.split('*');
		return {
			width:Number(s[0]),
			height:Number(s[1])
		};
	}
	// 文件尺寸监听
	function size_change(THIS){
		var str = $(THIS).find("option:selected").text();
		var size = strToSize(str);
		// 修改文件尺寸
		DEFINE.DEFAULT_TEMPLATE_PAGE_WITH = size.width;
		DEFINE.DEFAULT_TEMPLATE_PAGE_HEIGHT = size.height;
	}

	$(document).ready(
		function() {
			/* $(".selPageSize").combobox({
				url:appPath+'/itbMap/getSizeInfoList.action',
				valueField:'size_id',
				textField:'width',
				formatter:function(row){
					return 'W('+row.width+')'+'*H('+row.height+')';
				}
			}); */
			
			
			
			// 初始化尺寸列表
			$.post(
				appPath+'/itbMap/getSizeInfoList.action',
				function(ret) {
					if (ret && ret.length>0) {
						$('#selPageSize').html('');
						for(var i in ret){
							var txt = strFromSize(i, ret[i].size_id, ret[i].width, ret[i].height, ret[i].desc);
				            var sel = (i==0)?' selected="selected" ':'';
				            var str = '<option value ="'+ret[i].size_id+'" '+sel+'>'+txt+'</option>';
				            $('#selPageSize').append(str);
						}
						
						// 修改文件尺寸
						DEFINE.DEFAULT_TEMPLATE_PAGE_WITH = ret[0].width;
						DEFINE.DEFAULT_TEMPLATE_PAGE_HEIGHT = ret[0].height;
					}					
				}
			);
			
			if(!!g_id) {
				// 不能编辑
				$(".onekeymade").hide();
			} else if (!!g_tgId) {
				// 可以新建
				$(".onekeymade").show();
			}
		});
</script>
</head>
<body>
	<div class="wrapper">
		<!-- 右侧编辑区域 -->
		<div style="width:350px;height:500px;float:right;margin-top:60px;margin-right:20px;">
			<!-- 题纲编辑器－－数据版本号 -->
			<div id="version_div" style="border:solid 1px #ccc;">
				数据版本：<label id="version_p"/>
			</div>
			<!-- 分页编辑器－－设置分页信息 -->
			<div id="map_div" style="display:none;">
				<div style="border:solid 1px #ccc;margin-top:10px;">
					<span style="display:block;margin-left:10px;margin-top:8px;">页面尺寸：
						<select onchange="size_change(this)" id="selPageSize" class="selPageSize" name="selPageSize" style="width:180px"></select>
					</span>
					<span style="display:block;margin-left:10px;margin-top:8px;">模版页数：
						<input onkeyup="pageCount_keyup(this)" id="inputPageCount" value="1" style="width:30px" >
					</span>
				</div>
				<div style="border:solid 1px #ccc;margin-top:10px;">
					节点所在的页：
					<ul id="pageNumberList">
						<li><input type="checkbox" name="0" value="0" onchange="pageCheckChange(this)">第1页</input></li>
						<li><input type="checkbox" name="-1" value="-1" onchange="pageCheckAllChange(this)">全选</input></li>
					</ul>
				</div>
			</div>
			
		</div>
		<div class="demo">
			<!-- 其它弹窗 start -->
			<div class="cover_screen">
				<div class="progress_pic">
					<img src="images/ajax-loader.gif" />
				</div>
			</div>
			<div id="normalcon" class="tabcon">
				<div class="brain_title">
					<span id="message_box">[分页映射]</span>
				</div>
				<div id="jsmind_container" style="height:450px;border:solid 1px #ccc;"></div>
				
				<a class="onekeymade" style="display: none;">保存分页</a>
			</div>
			
			<div class="tanchu_black"></div>
			
			<div class="con_tanchu" id="con_tanchu_commt">
				<a href="#" class="name_close"></a>
				<div class="user_new_name" id="user_new_name_commt">
					<p class="tanchu_title">请输入备注</p>
					<input style="display: none" class="pop_hidden_doc_id" />
					<input type="text" value="请输入文字备注" class="pop_doc_name" />
					<a onclick="js_setComment(this)" style="margin-right: 74px" class="newname_sure">完成</a>
					<a onclick="js_removeComment(this)" class="newname_sure">删除</a>
				</div>
			</div>
			
			<div class="con_tanchu" id="pop_tg_rename">
				<a href="#" class="name_close"></a>
				<div class="user_new_name" id="div_tg_rename">
					<p class="tanchu_title">请输入分页映射文档名称</p>
					<input type="text" value="新建提纲" class="pop_doc_name" id="edit_map_rename" />
					<a onclick="js_RenameAndSave(this)" style="margin-right: 74px" class="newname_sure">保存</a>
					<a onclick="js_cancelRename(this)" class="newname_sure">取消</a>
				</div>
			</div>
			
			<div class="delete_reform" id="messageWindow">
				<a href="javascript:void(0)" class="delete_close"></a>
				<div class="msg_con">
					<p class="msg_title">消息？</p>
					<a href="javascript:void(0)" class="close_none">关闭</a>
				</div>
			</div>
			
			<script>
				function showMsg(msg) {
					$('.msg_title').html(msg);
					$("#messageWindow,.tanchu_black").show();
				}
				function closeMsg() {
					$('#messageWindow,.tanchu_black').hide();
				}
				$(".delete_close,.close_none").click(function() {
					$('#messageWindow,.tanchu_black').hide();
				});
			</script>
			<!-- 其它弹窗 end -->
			
			<!-- 分页弹窗 start -->
			<div class="tanchu_black"></div>
			<div class="delete_reform" id="pageWindow">
			    <a href="javascript:void(0)" class="delete_close"></a>
			    <div class="msg_con">
			        请选择节点所在的页<select class="page_list"></select>
			        <a href="javascript:selectOnePage()" class="close_none">确定</a>
			    </div>
			</div>
			<script>
				// 初始化page_list
				var g_pageCount = 1; // 总页数
				function init_page_list(curPage){
					$('.page_list').html('');
			        for(var i=0;i<g_pageCount+1;i++){
			            var p = i==0?"无":i;
			            var s = p==curPage?' selected="selected" ':'';
			            var str = '<option value ="'+i+'" '+s+'>'+p+'</option>';
			            $('.page_list').append(str);
			        }
				}
				
				
			    // 显示分页窗口，
			    // 参数：curPage 当前页码，0表示无效，1表示首页
			    // 参数：pageCount 总页数
			    // 参数：callback 选择后的回调,页码作为参数，0表示无效，1表示首页
			    var selectPageCallback = null;
			    function showPageWindow(curPage,callback) {
			        selectPageCallback=callback;
			        init_page_list( curPage)
			        $("#pageWindow,.tanchu_black").show();
			    }
			    function closePageWindow() {
			        $('#pageWindow,.tanchu_black').hide();
			    }
			    $(".delete_close,.close_none").click(function() {
			        $('#pageWindow,.tanchu_black').hide();
			    });
			    // 选择一个页
			    function selectOnePage(){
			        var p = $('.page_list').val();
			        if(selectPageCallback){
			            selectPageCallback(p);
			        }
			    }
			</script>
			<!-- 分页弹窗 end -->
			
			<script>
				// 分页编辑器－－设置节点的分页 -----------------------------------start
				function initPageList(pageCount){
					var t = $('#pageNumberList'); 
					t.html('');
					if(pageCount==1){
						t.append('<li><input type="checkbox" name="0" value="0" onchange="pageCheckChange(this)">第1页</input></li>');
						t.append('<li><input type="checkbox" name="-1" value="-1" onchange="pageCheckAllChange(this)">全选</input></li>');
					}else if(pageCount>1){
						for(var p=0;p<pageCount;p++){
							t.append('<li><input type="checkbox" name="'+p+'" value="'+p+'" onchange="pageCheckChange(this)">第'+(p+1)+'页</input></li>');
						}
						t.append('<li><input type="checkbox" name="-1" value="-1" onchange="pageCheckAllChange(this)">全选</input></li>');
					}
				};
				initPageList(1);
				
				// 清除界面上的选中状态
				function clearUIPageIndexs(){
					var t = $('#pageNumberList').find('li input');
					for(var p=0;p<t.length;p++){
						var o = t.eq(p);
						if(o.is(':checked') ){
							o.removeAttr("checked");	
						}
					}
				}
				
				// 设置节点的选中的页到版面上
				function setSelectNodePageIndexToUI(node){
					clearUIPageIndexs();
					var t = $('#pageNumberList'); 
					if(node.hasOwnProperty('relations')){
						for(var p=0;p<node.relations.length;p++){
							var ck = t.find('li input').eq(node.relations[p].page_index);
							ck.attr("checked", "checked");
						}
					}else{
						if(node.page_index){
							var ck = t.find('li input').eq(node.page_index);
							ck.attr("checked", "checked");
						}
					}
				}
				
				// 取得所有选中的pageIndex的数组
				function getSelectPageIndexs(){
					var ret = [];
					var t = $('#pageNumberList').find('li input');
					for(var p=0;p<t.length;p++){
						var o = t.eq(p);
						if(o.is(':checked') && o.val()>=0){
							ret.push(o.val()*1);
						}
					}
					return ret;
				}
				
				// 选中页
				function pageCheckChange(THIS){
					var t = $(THIS);
					if(t.is(':checked')){
						
						var v = getSelectPageIndexs();
						jm.setSelectNodePageIndexs(v);
					}else{
						// 清空选中节点的pageIndex
						jm.setSelectNodePageIndexs([]);
					}
				}
				// 全选所有页
				function pageCheckAllChange(THIS){
					var l = $('#pageNumberList').find('li input');
					var t = $(THIS);
					if(t.is(':checked')){
						l.attr("checked", "checked");	
						var v = getSelectPageIndexs();
						jm.setSelectNodePageIndexs(v);
					}else{
						l.removeAttr("checked");
						// 清空选中节点的pageIndex
						jm.setSelectNodePageIndexs([]);
					}
				}
				// 分页编辑器－－设置节点的分页 -----------------------------------end
			</script>

			<script>
				var jm = null; // 脑图
				$(function() {
					function load_jsmind() {
						var reqUrl = getAppServer();
						var param = {};
						
						if(!!g_id) {
							reqUrl += "/itbMap/getMapping.action";
							param.mapId = g_id || -1;
							
						} else if (!!g_tgId) {
							reqUrl += "/itbTg/getOutlineTmpl.action";
							param.tgId = g_tgId || -1;
						
						} else {
							return showMsg("参数错误！");
						}
						
						$.post(
							reqUrl,
							param,
							function(ret) {
								var tree = '{}';
								if (ret && ret.length>0) {
									tree = JSON.parse(ret[0].data);
								}else{
									return showMsg("数据获取失败！");
								}
								
								// 刷新界面显示－－－版本号显示
								$('#version_p').html(tree.version);
								// 刷新界面显示－－－根据模式显示右侧编辑区域内容
						        (function show_map_div(){
									$('#map_div').show();
						        })();
								
								
								var options = {
									container : 'jsmind_container',
									editable : true,
									theme : 'greensea',
									edit_mode: 3,// 分页映射
									callbacks : {
										message : function(_msg, _alert) {
											$('#message_box').html(_msg);
											if (_alert) {
												showMsg(_msg);
											}

											//console.log(_msg);
										},
										select:function(node){
						                	setSelectNodePageIndexToUI(node);
						                },
										/* add_page:function(node, cp, _callback){
						                    showPageWindow(cp,function(p){
						                        _callback(node,p)
						                    });

						                }, */
						                add_attribute:function(_txt, _callback){
						                	console.log(_txt);_callback(_txt);
						                }
									}
								};
								jm = jsMind.show_tree(options, tree);
								if (false) {
									jm.view.relayout();
								}
							}
						);
					}

					load_jsmind();
				});
			</script>
			<script>
				//测算弹出窗口的居中位置；
				var Owidth = 850;
				var Oheight = 578;
				var shijiW = (Owidth - 362) / 2;
				var shijiH = (Oheight - 214) / 2;
				$('.con_tanchu').css({
					top : shijiH,
					left : shijiW
				});

				$('.name_close,.newname_cancle,.newname_sure').click(
					function() {
						$('.user_new_name,.con_tanchu,.tanchu_black').hide();
						$('.tsq a').css('background', 'none').css('color','#049DD5');
					});

				var js_pop_callback = null;
				function js_popSetComment(comment, callback) {
					js_pop_callback = callback;

					var pop = $('#user_new_name_commt');
					var contanchu = $('#con_tanchu_commt');
					var tanchublack = $('.tanchu_black');
					//pop.find('.pop_hidden_doc_id').val(nodeid);
					pop.find('.pop_doc_name').val(comment);

					pop.show();
					contanchu.show();
					tanchublack.show();
				};
				function js_setComment(THIS) {
					var cur = $(THIS);
					var doc_name = cur.prev().val();
					var doc_id = cur.prev().prev().val();
					js_pop_callback(doc_name);
				}
				function js_removeComment(THIS) {
					js_pop_callback(null);
				}
				
				// 文档命名&保存
				function js_RenameAndSave(THIS) {
					var mapName = $('#edit_map_rename').val() || jm.mind.name;
					
					//if(mapName && mapName.length>0){
						jm.mind.name = mapName;// Rename
						
						
						
						// 将树转换成文档
						var ver = jm.mind_data_version();
				        var tree = jm.mind_2_tree();
				        var sjgTg;
				        var m_template;
				        if(tree.version>=3){
							// 版本3的转换方式	
				        	sjgTg =new SJGTGV3();
							sjgTg.fromJson(tree,tree.version);
					        m_template = TGToDocUtilV3.convert(sjgTg);
				        }else{
				        	// 版本1\2的转换方式	
				        	sjgTg =new SJGTG();
							sjgTg.fromJson(tree,0);
					        m_template = TGToDocUtil.convert(sjgTg);
				        }
						
				        var egretData = '{"name":"'+mapName+'","pagesData":'+m_template.body.toJsonPages4DB()+'}';
				        
				        if(m_template.body.pages == null
				        	|| m_template.body.pages.length<=0
				        	|| m_template.body.pages[0].content.length<=0){
				        	showMsg("未设置分页！");
				        	return;
				        }
						
						$('.cover_screen').show();
						$.post(
							getAppServer() + "/itbMapWeb/updMapping.action",
							{
								id: g_id,// 分页映射文档id
								tgId: g_tgId,// 提纲id
								sizeId: $('.selPageSize').val()||1,// 尺寸id
								name: mapName,// 文档名
								ver: ver,// 版本号
								jmData: sjgTg.toJson(),// mind数据
								egretData: egretData,// 分页数据
							},
							function(ret) {
								if (ret && ret.status=="ok") {
									showMsg("保存成功！");
									g_id=ret.mapId;
								}else{
									showMsg("保存失败！");
								}
								
								$('.cover_screen').hide();
							}
						);
					//}
				}
				function js_cancelRename(THIS){
					//
				}
			</script>
			<script>
				// 绑定[保存]点击事件
				$(function() {
					$('.onekeymade').click(
						function() {
							// 显示重命名界面
							var pop = $('#pop_tg_rename');
							var contanchu = $('#div_tg_rename');
							var tanchublack = $('.tanchu_black');
							$('#edit_map_rename').val(jm.mind.name);

							pop.show();
							contanchu.show();
							tanchublack.show();
						}
					);
				});
			</script>
			<script>
				$(function() {
					//
					
				});
			</script>

		</div>
	</div>
</body>
</html>
